home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 April / PC-WELT 4-2001.ISO / software / wsh / spkclip.exe / SpkClip.vbs
Encoding:
Text File  |  2001-01-25  |  3.0 KB  |  110 lines

  1. '==========================================================================
  2. '
  3. ' VBScript Source File 
  4. '
  5. ' NAME: SpkClip.vbs
  6. '
  7. ' AUTHOR: Thorsten Eggeling
  8. ' DATE  : 01.2001
  9. '
  10. ' COMMENT: Agent-Demo 2
  11. '          Sub readText(ptext) ist aus den Agen Powertoy ⁿbernommen
  12. '          ⌐ 1997/98 by Costas Andriotis, http://users.forthnet.gr/ath/costasan/
  13. '
  14. 'n÷tige Anpassungen: strCharacter, FileName
  15. '==========================================================================
  16. MsgBox("Bitte dieses Script vor dem Start erst anpassen! Script wird beendet.")
  17. Wscript.Quit
  18.  
  19. Dim objAgent 
  20. Dim chPath 
  21. Dim strCharacter
  22. Dim FileName 
  23. Dim fso
  24.  
  25. strCharacter = "merlin"
  26. FileName="Text2Speak.txt"
  27.  
  28.  
  29. Set objAgent = CreateObject("Agent.Control.1") 
  30.  If IsObject(objAgent) Then 
  31. objAgent.Connected = True 
  32. Set fso = CreateObject("Scripting.FileSystemObject") 
  33. Call Clibrd()
  34.  
  35. objAgent.Characters.Load strCharacter, strCharacter & ".acs"
  36.  
  37. Set char = objAgent.Characters (strCharacter) 
  38. char.Get "state", "Showing" 
  39. char.Get "state", "Speaking" 
  40. char.MoveTo 10, 10 
  41. char.commands.caption = "Lies es!"
  42. char.Show 
  43.  
  44. '************************************************************ 
  45. 'Aus Datei lesen
  46.             Const ForReading = 1, ForWriting = 2, ForAppending = 3 
  47.             Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 
  48.             Dim f, ts, s 
  49.             Set f = fso.GetFile(FileName) 
  50.             Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault) 
  51.  
  52.  Do While ts.AtEndOfStream <> True 
  53.  s = s+ts.ReadLine + Chr(13)
  54.  Loop 
  55.   ts.Close 
  56. ReadText(s)
  57.  
  58.   Set objRequest = Char.Hide
  59.    Do Until objRequest.Status = Complete
  60.       Wscript.Sleep 100
  61.    Loop
  62.  
  63.    Set Char = Nothing
  64.    objAgent.Characters.Unload strCharacter
  65.  
  66.    WScript.Quit
  67.  
  68. End If 
  69. '***************************************************
  70. Sub readText(ptext)
  71. On error resume next                                    ' This traps error in case the character doesn't have a 'Read' or 'ReadContinued' animation.
  72. ptext = ptext & "\mrk=1\"                            ' Exit properly
  73. char.play "Read" : firsttime = true
  74. for each paragraph in split(replace(ptext,chr(13),chr(10)),chr(10))
  75.     if (len(paragraph) > 80) and (not firsttime) then char.play "ReadContinued"
  76.     firsttime = false
  77.     for i = 1 to len(sentencebreaks)
  78.         sbreak = mid(sentencebreaks,i,1)
  79.         paragraph = replace(paragraph, sbreak & " ",sbreak & "╖")
  80.     next
  81.     for each sentence in split(paragraph,"╖")
  82.         char.speak sentence
  83.     next
  84. next
  85. end Sub
  86. '********************************************
  87. Sub Clibrd()
  88. Dim myClip
  89. Dim WshShell
  90. Dim fso
  91. Dim TempDir
  92.  
  93. TempDir=GetTempFolder
  94. FileName=TempDir & "\" & FileName
  95. Set myClip=CreateObject("pcwClip.pcwClip")
  96.    With myClip
  97.      .TextFileName=FileName
  98.      .GetText
  99.    End With
  100. End Sub
  101.  
  102. '********************************************
  103. 'Hilfsfunktionen
  104.  
  105. Function GetTempFolder
  106.    Dim tfolder, tname, tfile
  107.    Const TemporaryFolder = 2
  108.    Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
  109.    GetTempFolder = tFolder.Path
  110. End Function